<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="icon" href="../../logo.svg" />
    <title>事件处理</title>
  </head>
  <body>
    <div id="root">
      <h1>欢迎光临{{name}}！</h1>
      <div>
        <button v-on:click="showInfo1">点我提示信息</button>
        <button @click="showInfo2($event,666)">点我提示信息2</button>
      </div>
    </div>

    <script src="../../vue.js"></script>
    <script>
      Vue.config.productionTip = false; // 阻止 vue 在启动时生成生产提示。

      new Vue({
        el: "#root",
        data: {
          name: "yesen",
        },
        methods: {
          showInfo1(e) {
            console.log(e.target.innerText);
            alert(`你好，${this.name}!`);
          },
          showInfo2(e, num) {
            console.log(e.target.innerText);
            alert(`你好，${this.name} ${num}!`);
          },
        },
      });
    </script>
  </body>
</html>
